﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null && Session["password"] == null)
            {
                Response.Redirect("WebForm1.aspx");
            }
            if (Application["type"] == null)
            {
                Application["type"] = new Panel();
            }
            Panel1.Controls.Add((Control)Application["type"]);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = Session["username"].ToString();
            string text = TextBox1.Text;
            string time = DateTime.Now.ToString();

            Literal literal = new Literal();
            literal.Text = $"<b>{username}:</b>{time}<br/>{text}<br/>";
            Panel p = (Panel)Application["type"];
            p.Controls.Add(literal);
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            Session.Abandon();
        }
    }
}